/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package manager;

import entity.Employee;
import iface.IManager;
import java.util.ArrayList;

/**
 *
 * @author User
 */
public class EmployeeManager implements IManager<Employee> {

    private Manager manager;
    private ArrayList<Employee> employeeList;

    public EmployeeManager(Manager manager) {
        employeeList = new ArrayList<Employee>();
        this.manager = manager;
    }

    @Override
    public void add(Employee obj) {
        this.employeeList.add(obj);
    }

    @Override
    public void remove(Employee obj) {
        this.employeeList.remove(obj);
        obj.setStatus(false);
        this.manager.getDisabledEmployeeManager().add(obj);
    }

    @Override
    public Employee replace(int index, Employee obj) {
        return this.employeeList.set(index, obj);
    }

    @Override
    public int size() {
        return this.employeeList.size();
    }

    @Override
    public Employee get(int index) {
        return this.employeeList.get(index);
    }

    public Employee getByEmployeeID(int employeeID) {
        for(Employee employee: this.employeeList) {
            if(employee.getEmployeeID() == employeeID)
                return employee;
        }
        return null;
    }
    
    public ArrayList<Employee> getByDepartmentID(int departmentID) {
        ArrayList<Employee> alEmployees = new ArrayList<Employee>();
        for(Employee employee: this.employeeList) {
            if(employee.getDepartmentID() == departmentID) {
                alEmployees.add(employee);
            }
        }
        return alEmployees;
    }
    
    public ArrayList<Employee> getByEmployeeName(String employeeName) {
        ArrayList<Employee> alEmployee = new ArrayList<Employee>();
        for(Employee employee: this.employeeList) {
            if(employee.getEmployeeName().equals(employeeName))
                alEmployee.add(employee);
        }
        return alEmployee;
    }

    public ArrayList<Employee> getEmployeeList() {
        return employeeList;
    }
}
